/////////////////////////////////////////////////////////////////////////
// File:        TNod.h
// Purpose:     Implements TrayIconThread class wich change tray icon 
//              every short time (to see an animated icon)
// Author:      Tukero
// Copyright:   (c) Tukero <tukero@gmail.com>
// Licence:     GNU/LGPL v3
/////////////////////////////////////////////////////////////////////////
#include "TrayIconThread.h"
#include "CurrentAppHeaders.h"

TrayIconThread::TrayIconThread(TrayIcon *trayIcon)
        : wxThread()
{
    m_TrayIcon = trayIcon;
}

void TrayIconThread::OnExit()
{
}

void *TrayIconThread::Entry()
{
    bool up = true;
    int index = 0;

    while(!TestDestroy())
    {
        if (index == 0)
        {
            m_TrayIcon->SetIcon(wxICON(tnodicop1), wxGetApp().GetTrayIconTitle());
            for (int c=0;c<10 && !TestDestroy();c++)
                wxThread::Sleep(200);
        }
        else if (index == 1)
            m_TrayIcon->SetIcon(wxICON(tnodicop2), wxGetApp().GetTrayIconTitle());
        else if (index == 2)
            m_TrayIcon->SetIcon(wxICON(tnodicop3), wxGetApp().GetTrayIconTitle());
        else
        {
            m_TrayIcon->SetIcon(wxICON(tnodicop4), wxGetApp().GetTrayIconTitle());
            for (int c=0;c<3 && !TestDestroy();c++)
                wxThread::Sleep(200);
        }

        wxThread::Sleep(120);
        if (up) 
        {
            index++;
            if (index >= 3) up = false;
        }
        else
        {
            index--;
            if (index <= 0) up = true;
        }
    }
    return NULL;
}
